// test.c  
#include <stdio.h>  
#include <string.h>  
#include "sm3.h"  

// 打印缓冲区为十六进制格式  
void dumpbuf(const unsigned char *buf, int len) {  
    for (int i = 0; i < len; i++) {  
        printf("%02x", buf[i]);  
        if (((i + 1) % 4) == 0) printf(" ");  
    }  
    printf("\n");  
}  

int main(int argc, char *argv[])  
{  
    const unsigned char *input = (const unsigned char*)"abc";  
    const unsigned char *key = (const unsigned char*)"123456";  
    int ilen = strlen((const char *)input); // 输入数据长度  
    int keylen = strlen((const char *)key); // 密钥长度  
    unsigned char output[32];  

    printf("Message: %s\n", input);  

    sm3_hmac(key, keylen, input, ilen, output);  
    printf("HMAC:   ");  
    dumpbuf(output, 32);  

    return 0;  
}
